package com.midian.service.banner.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.midian.common.dao.BaseDaoTemplet;
import com.midian.common.dao.OrderHelper;
import com.midian.common.dao.SearchHelper;
import com.midian.common.dao.SearchHelper.Type;
import com.midian.common.exception.BizException;
import com.midian.common.pager.Pager;
import com.midian.model.banner.Banner;
import com.midian.service.common.BaseService;
import com.midian.service.banner.IBannerService;

/**
 * banner广告业务实现类
 * @author Mengfh
 *
 */
@Service("bannerService")
public class BannerServiceImpl extends BaseService implements IBannerService {
	/**banner广告DAO*/
	private BaseDaoTemplet<Banner> bannerDAO;
	
	@Resource(name = "bannerDAO")
	public void setBannerDAO(BaseDaoTemplet<Banner> bannerDAO) {
		this.bannerDAO = bannerDAO;
	}

	@Override
	public Banner add(Banner target) throws BizException {
		this.bannerDAO.add(target);
		return target;
	}

	@Override
	public void update(Banner target) throws BizException {
		this.bannerDAO.updateByConvertHql(target);
	}

	@Override
	public void delete(Serializable id) throws BizException {
		this.bannerDAO.delete(id);
	}

	@Override
	public void delete(Serializable[] ids) throws BizException {
		this.bannerDAO.delete(ids);
	}

	@Override
	public Banner get(Serializable id) throws BizException {
		return this.bannerDAO.get(id);
	}

	@Override
	public List<Banner> showList(Banner target, Pager pager, List<OrderHelper> helper) throws BizException {
		return this.bannerDAO.find(target, getSearchHelper(), helper, pager);
	}

	@Override
	public void opDelFlag(Serializable[] ids, Integer status) throws BizException {
		this.bannerDAO.opDelFlag(ids, status);
	}

	@Override
	protected List<SearchHelper> getSearchHelper() {
		String[] attrs = {"delFlag"};
		Type[] types = {Type.EQ};
		return SearchHelper.getSearchList(attrs, types);
	}
}
